<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
        <meta name="viewport" content="width=device-width,initial-scale=1.0">
		<title></title>
		<link rel="stylesheet" type="text/css" href="/static/css/main.css">
		<link rel="stylesheet" type="text/css" href="/static/css/qr-code.css">
		<script src="/static/js/jquery-2.1.1.min.js" type="text/javascript"></script>
		<script type="text/javascript" src="http://static.runoob.com/assets/qrcode/qrcode.min.js"></script>
	</head>
	<body>
		{% include 'base.html' with title='身份码' %}
        
        <br><br>
        
        <input id="text" type="text" style="text-align: center" value={{ card.card_id }} /><br />
        <div id="qrcode" ></div>
        
        
  <script type="text/javascript">
var qrcode = new QRCode(document.getElementById("qrcode"), {
	width : 350,
	height : 350,
});

function makeCode () {		
	var elText = document.getElementById("text");
	
	if (!elText.value) {
		alert("Input a text");
		elText.focus();
		return;
	}
	
	qrcode.makeCode(elText.value);
}

makeCode();

$("#text").
	on("blur", function () {
		makeCode();
	}).
	on("keydown", function (e) {
		if (e.keyCode == 13) {
			makeCode();
		}
	});
</script>
        
	</body>
	
</html>
